import time
from functools import wraps

def run_time(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        start_time = time.time()
        result = func(*args, **kwargs)
        end_time = time.time()
        
        # 计算执行时间（以秒为单位）
        total_time = end_time - start_time
        
        # 转换为小时、分钟、秒、毫秒
        hours = int(total_time // 3600)
        minutes = int((total_time % 3600) // 60)
        seconds = int(total_time % 60)
        milliseconds = int((total_time - int(total_time)) * 1000)
        
        print(f"Function '{func.__name__}' runtime: {hours:02}:{minutes:02}:{seconds:02}:{milliseconds:03}")
        return result
    
    return wrapper


if __name__ == "__main__":
    # 使用示例
    @run_time
    def example_function():
        time.sleep(1.234)  # 模拟运行时间

    example_function()
